$(function(){
	getPatterns();
});

function getPatterns(){
	var IPS = GetQueryString("IPS");
	$.ajax({
	    type:"POST",
	    url:constUrl+"MonitorPatternServlet",
	    dataType:"json",
	    data: {
	        operateType: "showAll"
	    },
	    success:function(res){
	        let data = res.datas;
	        for(let i=0;i<data.length;i++) {
	            let temp_html = '<label class="am-btn am-btn-primary" style="margin-left:25px;margin-top:23px"><input type="radio" name="options" id="option'+i+'" onclick="changeMode(\''+data[i].patternName+'\',\''+IPS+'\')">'+data[i].patternName+'</label>'
	            $("#content").append(temp_html);
	        }
	    },
	    error:function () {
	    }
	});
}


function changeMode(modeName,IPS){

//	alert(modeName+","+IPS);
	layer.confirm('确定要切换模式吗？', {
        btn: ['确定','取消'] //按钮
    }, function(){
    	$.ajax({
    		type:"GET",
            url:constUrl+"ws/remote/mode/change",
            dataType:"json",
            data: {
            	startType: modeName,
            	startIPS:IPS
               
            },
            success:function(data){
            	layer.msg(data.data, {
                    time: 1500 //1s后自动关闭
                });
            },error:function(data){
            	layer.msg(data.data, {
                    time: 1500 //1s后自动关闭
                });
            }
    	});
        layer.closeAll('dialog');
    }, function(){
        layer.msg('取消切换', {
            time: 1000 //1s后自动关闭
        });
    });
}